/**
 * @Author: SevDaisy十七散人 
 * @Date: 2020-07-05 16:29:00
 */
package zyy.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import zyy.util.Bus;
import zyy.util.BusinessException;

public class FrmUserInfo extends JDialog implements ActionListener {
  private static final long serialVersionUID = -1544763493327512880L;

  private JLabel uName = new JLabel("用户昵称：");
  public JLabel uNameCon = new JLabel();
  private JLabel lName = new JLabel("用户账户：");
  public JLabel lNameCon = new JLabel();
  private JLabel uCity = new JLabel("所在城市：");
  public JLabel uCityCon = new JLabel();
  private JLabel uEmail = new JLabel("电子邮箱：");
  public JLabel uEmailon = new JLabel();
  private JLabel uTel = new JLabel("电话号码：");
  public JLabel uTeleCon = new JLabel();
  private JLabel isVIP = new JLabel("是否VIP：");
  public JLabel isVIPCon = new JLabel();
  private JLabel vipTime = new JLabel("VIP有效期：");
  public JLabel vipTimeCon = new JLabel();
  private JLabel oCnt = new JLabel("订单总数：");
  public JLabel oCntCon = new JLabel();
  private JLabel oSum = new JLabel("订单总金额：");
  public JLabel oSumCon = new JLabel();

  private JButton setVIP = new JButton("申请VIP");
  private JButton changePwd = new JButton("修改密码");
  private JButton exit = new JButton("退出");

  private JPanel text = new JPanel();
  private JPanel btns = new JPanel();

  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == this.setVIP) {
      new FrmVipTime("用户");
    } else if (e.getSource() == this.changePwd) {
      new FrmUserNewPwd();
    } else if (e.getSource() == this.exit) {
      this.setVisible(false);
    }
  }

  public FrmUserInfo(int UserID) {
    // JDialog 基础设置
    {
      this.setTitle("外卖助手 用户 信息查询");
      this.setSize(450, 360);
      this.setLocationRelativeTo(null);
      this.setVisible(true);
      Bus.fUserInfo = this;
    }
    // body 布局
    {
      this.getContentPane().setLayout(new BorderLayout());// 如果这里不设置的话，商品信息表将无法展示
      this.getContentPane().add(this.text, BorderLayout.CENTER);
      this.getContentPane().add(this.btns, BorderLayout.SOUTH);
    }
    // text 相关配置
    {
      // this.text.setLayout(new FlowLayout(FlowLayout.LEFT));
      this.text.setLayout(new GridLayout(9, 2, 10, 10));
      this.text.add(this.uName);
      this.text.add(this.uNameCon);
      this.text.add(this.lName);
      this.text.add(this.lNameCon);
      this.text.add(this.uCity);
      this.text.add(this.uCityCon);
      this.text.add(this.uEmail);
      this.text.add(this.uEmailon);
      this.text.add(this.uTel);
      this.text.add(this.uTeleCon);
      this.text.add(this.isVIP);
      this.text.add(this.isVIPCon);
      this.text.add(this.vipTime);
      this.text.add(this.vipTimeCon);
      this.text.add(this.oCnt);
      this.text.add(this.oCntCon);
      this.text.add(this.oSum);
      this.text.add(this.oSumCon);
    }
    // btns 相关配置
    {
      this.btns.setLayout(new FlowLayout(FlowLayout.RIGHT));
      this.btns.add(this.changePwd);
      this.btns.add(this.setVIP);
      this.btns.add(this.exit);
      this.changePwd.addActionListener(this);
      this.setVIP.addActionListener(this);
      this.exit.addActionListener(this);
      Bus.jButtonZYYStyle(this.changePwd);
      Bus.jButtonZYYStyle(this.setVIP);
      Bus.jButtonZYYStyle(this.exit);
    }
    // 内容数据设置
    {
      try {
        Bus.userManager.loadUserInfo(this);
      } catch (BusinessException e) {
        JOptionPane.showMessageDialog(null, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
      }
    }
  }
}